package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.SettingsMApper;
import com.tanhua.model.db.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingsApi {
    @Autowired
    private SettingsMApper settingsMApper;

    //修改
    @Override
    public void update(Settings settings) {
        settingsMApper.updateById(settings);
    }

    //保存
    @Override
    public void save(Settings settings) {
        settingsMApper.insert(settings);
    }

    //根据id查询
    @Override
    public Settings findById(Long userId) {
        LambdaQueryWrapper<Settings> settingsWrapper = new LambdaQueryWrapper<>();
        settingsWrapper.eq(Settings::getUserId, userId);
        Settings settings = settingsMApper.selectOne(settingsWrapper);
        return settings;
    }
}
